package com.airlines.crewassignment.controller.crew;

import com.airlines.common.Page;
import com.airlines.crewassignment.service.crew.CrewDutyHoursService;
import com.airlines.crewassignment.service.crew.CrewFlightExperienceService;
import com.airlines.crewassignment.service.linkline.FlightInfoService;
import com.airlines.crewassignment.service.scheduleAuthority.ScheduleAuthorityService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.text.ParseException;

/**
 * @author xxxx
 * @date 2018/8/20
 * @company xxxx Airlines
 * @description 执勤期小时统计汇总
 */
@Controller
@RequestMapping("/crewDutyHours")
public class CrewDutyHoursController {
    private static final String PREFIX = "/dutyHours";

    @Autowired
    private CrewFlightExperienceService crewFlightExperienceService;
    @Autowired
    private ScheduleAuthorityService scheduleAuthorityService;
    @Autowired
    private FlightInfoService flightInfoService;
    @Autowired
    private CrewDutyHoursService crewDutyHoursService;



    @RequestMapping("toListPage")
    public String toListPage(String dutyCode,Model model) {
        model.addAttribute("dutyCode",dutyCode);
        return PREFIX+"/dutyHoursList";
    }
    @RequestMapping("toEditPage")
    public String toEditPage(String workcode,String month,String fullName,Model model) {
        model.addAttribute("workcode",workcode);
        model.addAttribute("month",month);
        return PREFIX+"/dutyHoursEdit";
    }


    @RequestMapping(value = "/list")
    @ResponseBody
    //@RequiresPermissions("crewFlightHours:list")
    public Page list(String fullName, String dutyCode,Integer year, Integer offset, Integer limit) throws ParseException {
        return crewDutyHoursService.getPage(fullName,dutyCode,year,offset,limit);
    }

    /**
     * 获取员工每月飞行详情
     * @param workcode
     * @param month
     * @return
     */
    @RequestMapping(value = "/listItems")
    @ResponseBody
    //@RequiresPermissions("crewFlightHours:list")
    public String listItems(String workcode,String month) {
        return crewDutyHoursService.listItems(workcode,month);
    }


    @RequestMapping(value = "/job")
    @ResponseBody
    public String job() throws ParseException {
        return crewDutyHoursService.job();
    }
}
